<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Abstraction Layer (HAL)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Hardware Abstraction Layer (HAL)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__hal__trng.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">TRNG (True Random Number Generator)<div class="ingroups"><a class="el" href="group__group__hal.html">HAL Drivers</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >High level interface to the True Random Number Generator (TRNG). </p>
<p >This block uses dedicated hardware to efficiently generate true random numbers.</p>
<h1><a class="anchor" id="subsection_trng_features"></a>
Features</h1>
<ul>
<li>Number generated is statistically random</li>
<li>Based on physical processes exhibiting random variation</li>
<li>Generated sequences of numbers cannot be duplicated by running the process again</li>
<li>Uses polynomial generators with fixed and programmable polynomials</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This driver is not intended to be used as a security library. If a full security library is needed something like Mbed TLS should be used instead.</dd></dl>
<h1><a class="anchor" id="subsection_trng_quickstart"></a>
Quick Start</h1>
<p ><a class="el" href="group__group__hal__trng.html#ga499f730a1bf8a19bbd685bb40e7a0887">cyhal_trng_init</a> initializes the TRNG and passes a pointer to the <b>TRNG</b> block through the <b>obj</b> object of type <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a>.</p>
<p >See <a class="el" href="group__group__hal__trng.html#subsection_trng_use_case_1">Simple TRNG number generation example</a>.</p>
<h2><a class="anchor" id="subsection_trng_use_case_1"></a>
Simple TRNG number generation example</h2>
<p >The following snippet initializes a TRNG and generates a true random number.</p>
<div class="fragment"><div class="line"> </div>
<div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>    rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> trng_obj;</div>
<div class="line">    uint32_t     rnd_num;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize the true random number generator block</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__trng.html#ga499f730a1bf8a19bbd685bb40e7a0887">cyhal_trng_init</a>(&amp;trng_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Generate a true random number</span></div>
<div class="line">    rnd_num = <a class="code hl_function" href="group__group__hal__trng.html#ga9675bb0235fcd4500d4f77686b000f59">cyhal_trng_generate</a>(&amp;trng_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Release the true random number generator block</span></div>
<div class="line">    <span class="comment">// Note: Free only if not required anymore</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__trng.html#gaf11f2e6c4841065309ecfeab50f488eb">cyhal_trng_free</a>(&amp;trng_obj);</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_structcyhal__trng__t"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a></div><div class="ttdoc">RNG object.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:1143</div></div>
<div class="ttc" id="agroup__group__hal__trng_html_ga499f730a1bf8a19bbd685bb40e7a0887"><div class="ttname"><a href="group__group__hal__trng.html#ga499f730a1bf8a19bbd685bb40e7a0887">cyhal_trng_init</a></div><div class="ttdeci">cy_rslt_t cyhal_trng_init(cyhal_trng_t *obj)</div><div class="ttdoc">Initialize the random number generator.</div></div>
<div class="ttc" id="agroup__group__hal__trng_html_ga9675bb0235fcd4500d4f77686b000f59"><div class="ttname"><a href="group__group__hal__trng.html#ga9675bb0235fcd4500d4f77686b000f59">cyhal_trng_generate</a></div><div class="ttdeci">uint32_t cyhal_trng_generate(const cyhal_trng_t *obj)</div><div class="ttdoc">Generate a random number.</div></div>
<div class="ttc" id="agroup__group__hal__trng_html_gaf11f2e6c4841065309ecfeab50f488eb"><div class="ttname"><a href="group__group__hal__trng.html#gaf11f2e6c4841065309ecfeab50f488eb">cyhal_trng_free</a></div><div class="ttdeci">void cyhal_trng_free(cyhal_trng_t *obj)</div><div class="ttdoc">Release the random number generator.</div></div>
<div class="ttc" id="agroup__group__result_html_gaca79700fcc701534ce61778a9bcf57d1"><div class="ttname"><a href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a></div><div class="ttdeci">uint32_t cy_rslt_t</div><div class="ttdoc">Provides the result of an operation as a structured bitfield.</div><div class="ttdef"><b>Definition:</b> cy_result.h:438</div></div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="groups" name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hal__results__trng"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__results__trng.html">TRNG HAL Results</a></td></tr>
<tr class="memdesc:group__group__hal__results__trng"><td class="mdescLeft">&#160;</td><td class="mdescRight">TRNG specific return codes. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga499f730a1bf8a19bbd685bb40e7a0887"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__trng.html#ga499f730a1bf8a19bbd685bb40e7a0887">cyhal_trng_init</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> *obj)</td></tr>
<tr class="memdesc:ga499f730a1bf8a19bbd685bb40e7a0887"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the random number generator.  <a href="group__group__hal__trng.html#ga499f730a1bf8a19bbd685bb40e7a0887">More...</a><br /></td></tr>
<tr class="separator:ga499f730a1bf8a19bbd685bb40e7a0887"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf11f2e6c4841065309ecfeab50f488eb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__trng.html#gaf11f2e6c4841065309ecfeab50f488eb">cyhal_trng_free</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> *obj)</td></tr>
<tr class="memdesc:gaf11f2e6c4841065309ecfeab50f488eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release the random number generator.  <a href="group__group__hal__trng.html#gaf11f2e6c4841065309ecfeab50f488eb">More...</a><br /></td></tr>
<tr class="separator:gaf11f2e6c4841065309ecfeab50f488eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9675bb0235fcd4500d4f77686b000f59"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__trng.html#ga9675bb0235fcd4500d4f77686b000f59">cyhal_trng_generate</a> (const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> *obj)</td></tr>
<tr class="memdesc:ga9675bb0235fcd4500d4f77686b000f59"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate a random number.  <a href="group__group__hal__trng.html#ga9675bb0235fcd4500d4f77686b000f59">More...</a><br /></td></tr>
<tr class="separator:ga9675bb0235fcd4500d4f77686b000f59"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga499f730a1bf8a19bbd685bb40e7a0887" name="ga499f730a1bf8a19bbd685bb40e7a0887"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga499f730a1bf8a19bbd685bb40e7a0887">&#9670;&nbsp;</a></span>cyhal_trng_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_trng_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the random number generator. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a random number generator object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request</dd></dl>
<p>Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> if the operation was successful </p>

</div>
</div>
<a id="gaf11f2e6c4841065309ecfeab50f488eb" name="gaf11f2e6c4841065309ecfeab50f488eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf11f2e6c4841065309ecfeab50f488eb">&#9670;&nbsp;</a></span>cyhal_trng_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_trng_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Release the random number generator. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">obj</td><td>The random number generator object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga9675bb0235fcd4500d4f77686b000f59" name="ga9675bb0235fcd4500d4f77686b000f59"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9675bb0235fcd4500d4f77686b000f59">&#9670;&nbsp;</a></span>cyhal_trng_generate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t cyhal_trng_generate </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__trng__t">cyhal_trng_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Generate a random number. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The random number generator object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The random number generated</dd></dl>
<p>See <a class="el" href="group__group__hal__trng.html#subsection_trng_use_case_1">Simple TRNG number generation example</a> </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Hardware Abstraction Layer (HAL)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
